package com.example.Lezedata.ui.dataPage.subVc;

import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.example.Lezedata.R;
import com.example.Lezedata.util.GBUtil;

import bid.Bid;

public class DataNodeListCell extends LinearLayout {

    public Bid.NodePool pool;

    private TextView textViewIP;
    private TextView textViewArea;
    private TextView textViewCon;
    private TextView textViewChe;
    private TextView textViewInv;
    private TextView textViewTime;
    public static DataNodeListCell newInstance(Context context , ViewGroup viewGroup) {
        DataNodeListCell cell = (DataNodeListCell)LayoutInflater.from(context).inflate(R.layout.node_list,viewGroup,false);
        return cell;
    }

    public DataNodeListCell(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
         textViewIP = findViewById(R.id.textView_ip);
         textViewArea =findViewById(R.id.textView_area);
         textViewCon = findViewById(R.id.textView_peercount);
         textViewChe = findViewById(R.id.textView_chequecount);
         textViewInv =findViewById(R.id.textView_chequevaildcount);
        textViewTime=findViewById(R.id.textView_time);
    }

    public void setPool(Bid.NodePool pool) {
        this.pool = pool;

        textViewIP.setText(pool.getIpPub());
        textViewArea.setText(pool.getArea());
        textViewCon.setText(String.valueOf(pool.getPeerCount()));
        textViewChe.setText(String.valueOf(pool.getChequeCount()));
        textViewInv.setText(String.valueOf(pool.getChequeVaildCount()));

        textViewTime.setText( GBUtil.formatDateTimeHaveHour(pool.getCreateTime()));
    }
}
